import 'package:FiduMart/generated/json/base/json_convert_content.dart';
import 'package:FiduMart/core/network/model/association_entity.dart';

AssociationEntity $AssociationEntityFromJson(Map<String, dynamic> json) {
  final AssociationEntity associationEntity = AssociationEntity();
  final List<AssociationProject>? project = (json['project'] as List<dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<AssociationProject>(e) as AssociationProject)
      .toList();
  if (project != null) {
    associationEntity.project = project;
  }
  return associationEntity;
}

Map<String, dynamic> $AssociationEntityToJson(AssociationEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['project'] = entity.project?.map((v) => v.toJson()).toList();
  return data;
}

extension AssociationEntityExt on AssociationEntity {
  AssociationEntity copyWith({
    List<AssociationProject>? project,
  }) {
    return AssociationEntity()
      ..project = project ?? this.project;
  }
}

AssociationProject $AssociationProjectFromJson(Map<String, dynamic> json) {
  final AssociationProject associationProject = AssociationProject();
  final String? symbol = jsonConvert.convert<String>(json['symbol']);
  if (symbol != null) {
    associationProject.symbol = symbol;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    associationProject.name = name;
  }
  final String? cmc = jsonConvert.convert<String>(json['cmc']);
  if (cmc != null) {
    associationProject.cmc = cmc;
  }
  final String? logo = jsonConvert.convert<String>(json['logo']);
  if (logo != null) {
    associationProject.logo = logo;
  }
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    associationProject.id = id;
  }
  final int? pairId = jsonConvert.convert<int>(json['pair_id']);
  if (pairId != null) {
    associationProject.pairId = pairId;
  }
  return associationProject;
}

Map<String, dynamic> $AssociationProjectToJson(AssociationProject entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['symbol'] = entity.symbol;
  data['name'] = entity.name;
  data['cmc'] = entity.cmc;
  data['logo'] = entity.logo;
  data['id'] = entity.id;
  data['pair_id'] = entity.pairId;
  return data;
}

extension AssociationProjectExt on AssociationProject {
  AssociationProject copyWith({
    String? symbol,
    String? name,
    String? cmc,
    String? logo,
    int? id,
    int? pairId,
  }) {
    return AssociationProject()
      ..symbol = symbol ?? this.symbol
      ..name = name ?? this.name
      ..cmc = cmc ?? this.cmc
      ..logo = logo ?? this.logo
      ..id = id ?? this.id
      ..pairId = pairId ?? this.pairId;
  }
}